package 面向对象;

public class 方法 {

    public static void main(String[] args) throws IllegalAccessException {
        Person ming = new Person();
        ming.setName("Li Nan");
        ming.setAge(18);
        System.out.println(ming.getName() + "," + ming.getAge());
    }

}
class Person{
    private String name;
    private int age;

    public String getName(){
        return this.name;
    }

    public void setName(String name){
        this.name = name;
    }
    public int getAge(){
        return this.age;
    }

    public void setAge (int age) throws IllegalAccessException {
        if (age<0 || age>200){
            throw new IllegalAccessException("invalid age value");
        }
        this.age = age;
    }
}

